﻿using School;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestStudent
{
    
    
    /// <summary>
    ///This is a test class for StudentTest and is intended
    ///to contain all StudentTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StudentTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Student Constructor
        ///</summary>
        [TestMethod()]
        public void StudentConstructorTest()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber);
            Assert.AreEqual(name, target.Name);
            Assert.AreEqual(fNumber, target.FNumber);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void StudentNameCheck()
        {
            string name = ""; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void StudentNumberCheck()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 1000; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber);
            //Assert.IsTrue(fNumber <= 99999 && fNumber >= 10000);
        }

        /// <summary>
        ///A test for Equals
        ///</summary>
        [TestMethod()]
        public void EqualsTestPass()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            object o = new Student("Filip", 71057); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.Equals(o);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void EqualsTestFail()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            object o = 5; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.Equals(o);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void EqualsTestFail2()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            object o = new Student ("Filip", 71000); // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.Equals(o);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetHashCode
        ///</summary>
        [TestMethod()]
        public void GetHashCodeTest()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            int expected = "Filip".GetHashCode() ^ 71057.GetHashCode(); // TODO: Initialize to an appropriate value
            int actual;
            actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for FNumber
        ///</summary>
        [TestMethod()]
        public void FNumberTest()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            int expected = 71057; // TODO: Initialize to an appropriate value
            int actual;
            target.FNumber = expected;
            actual = target.FNumber;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Name
        ///</summary>
        [TestMethod()]
        public void NameTest()
        {
            string name = "Filip"; // TODO: Initialize to an appropriate value
            int fNumber = 71057; // TODO: Initialize to an appropriate value
            Student target = new Student(name, fNumber); // TODO: Initialize to an appropriate value
            string expected = "Filip"; // TODO: Initialize to an appropriate value
            string actual;
            target.Name = expected;
            actual = target.Name;
            Assert.AreEqual(expected, actual);
        }
    }
}
